home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / WizardPanel.java < prev    next >
Text File  |  1998-10-04  |  5KB  |  215 lines

  1. package com.symantec.itools.frameworks.wizard;
  2.  
  3.  
  4. import java.awt.*;
  5. import java.util.Vector;
  6. import com.sun.java.swing.JPanel;
  7.  
  8.  
  9. /**
  10.  * @author Symantec Internet Tools Division
  11.  * @version 1.0
  12.  * @since VCafe 3.0
  13.  */
  14.  
  15. public class WizardPanel
  16.     extends JPanel
  17.     implements WizardPage,
  18.                WizardSummaryPage
  19. {
  20.  
  21.     /**
  22.      * @since VCafe 3.0
  23.      */
  24.     protected WizardController controller;
  25.  
  26.     protected WizardPanel()
  27.     {
  28.     }
  29.  
  30.     protected WizardPanel(WizardController c)
  31.     {
  32.         controller = c;
  33.     }
  34.  
  35.     /**
  36.      * @param c TODO
  37.      * @since VCafe 3.0
  38.      */
  39.  
  40.     public void setWizardController(WizardController c)
  41.     {
  42.         controller = c;
  43.     }
  44.  
  45.     /**
  46.      * @since VCafe 3.0
  47.      */
  48.  
  49.     public WizardController getWizardController()
  50.     {
  51.         return controller;
  52.     }
  53.  
  54.     /**
  55.      * @since VCafe 3.0
  56.      */
  57.  
  58.     public String getPanelTitle()
  59.     {
  60.         return null;
  61.     }
  62.  
  63.     /**
  64.      * @param currentCursor TODO
  65.      * @since VCafe 3.0
  66.      */
  67.  
  68.     public synchronized void setAllCursors(Cursor currentCursor)
  69.     {
  70.         Wizard wiz = null;
  71.         if (controller != null)
  72.         {
  73.             wiz = controller.getWizard();
  74.             if (wiz != null)
  75.             {
  76.                 wiz.setCursor(currentCursor);
  77.                 setAllContainedCursors(wiz, currentCursor);
  78.                 Component parent = wiz.getParentFrame();
  79.                 if (parent != null)
  80.                     parent.setCursor(currentCursor);
  81.             }
  82.         }
  83.     }
  84.  
  85.     /**
  86.      * @param outerContainer TODO
  87.      * @param currentCursor TODO
  88.      * @since VCafe 3.0
  89.      */
  90.  
  91.     private void setAllContainedCursors(Container outerContainer, Cursor currentCursor)
  92.     {
  93.         Component[] allComponents = getAllComponents(outerContainer);
  94.         for (int i = 0; i < allComponents.length; i++)
  95.         {
  96.             allComponents[i].setCursor(currentCursor);
  97.         }
  98.     }
  99.  
  100.     /**
  101.      * @param parent TODO
  102.      * @since VCafe 3.0
  103.      */
  104.  
  105.     private synchronized Component[] getAllComponents(Container parent)
  106.     {
  107.         Vector holdComponents = new Vector();
  108.         Component[] ret = null;
  109.         if (parent != null)
  110.         {
  111.             // set current container
  112.             Container current = parent;
  113.             int vectorPos = -1;
  114.             while (current != null)
  115.             {
  116.                 // Add all the containers components to the holdComponents vector
  117.                 Component[] c = current.getComponents();
  118.                 if (c != null)
  119.                 {
  120.                     for (int i = 0; i < c.length; i++)
  121.                     {
  122.                         holdComponents.addElement(c[i]);
  123.                     }
  124.                 }
  125.                 // increment the position pointer within the vector and reset current container to null
  126.                 vectorPos++;
  127.                 current = null;
  128.                 while (holdComponents.size() > vectorPos)
  129.                 {
  130.                     // walk through existing vector searching for next container
  131.                     Component temp = (Component) holdComponents.elementAt(vectorPos);
  132.                     if (temp instanceof Container)
  133.                     {
  134.                         // when the container is found, break
  135.                         current = (Container) temp;
  136.                         break;
  137.                     }
  138.                     else
  139.                     {
  140.                         // keep looking
  141.                         vectorPos++;
  142.                     }
  143.                 }
  144.             }
  145.             // build component array when all components have been found
  146.             if (holdComponents.size() > 0)
  147.             {
  148.                 int count = holdComponents.size();
  149.                 ret = new Component[count];
  150.                 holdComponents.copyInto(ret);
  151.             }
  152.         }
  153.         
  154.         return ret;
  155.     }
  156.  
  157.     /**
  158.      * @since VCafe 3.0
  159.      */
  160.  
  161.     public void entering()
  162.     {
  163.     }
  164.  
  165.     /**
  166.      * @since VCafe 3.0
  167.      */
  168.  
  169.     public boolean exiting()
  170.     {
  171.         return (true);
  172.     }
  173.  
  174.     /**
  175.      * @since VCafe 3.0
  176.      */
  177.  
  178.     public void finish()
  179.     {
  180.     }
  181.  
  182.     /**
  183.      * @since VCafe 3.0
  184.      */
  185.  
  186.     public void cancel()
  187.     {
  188.     }
  189.  
  190.     /**
  191.      * @param dataName TODO
  192.      * @since VCafe 3.0
  193.      */
  194.  
  195.     public Object getData(String dataName)
  196.     {
  197.         return (null);
  198.     }
  199.  
  200.     /**
  201.      * @since VCafe 3.0
  202.      */
  203.     public Summary getSummary()
  204.     {
  205.         return (null);
  206.     }
  207.  
  208.     /**
  209.      * @since VCafe 3.0
  210.      */
  211.     public WizardSummary getWizardSummary()
  212.     {
  213.         return (null);
  214.     }
  215. }